package com.zx.bean;
import java.sql.Connection;
import java.sql.DriverManager;


public class DBConnection implements IDatabaseConnection{
	 private  String dbDriver="jdbc:oracle:thin:@localhost:1521:orcl";
	    private  String dbURL="oracle.jdbc.driver.OracleDriver";
	    private  String dbAdmin="sjztypt";
	    private  String dbPass="zxkj";
	    private Connection conn=null;
	   
	    public static void main(String[] args) throws Exception{
	       DBConnection db=new DBConnection();
	       db.getConnection();
	       boolean bFlag=db.closeConnection();
	       System.out.println(bFlag);
	    }
	   
	    public DBConnection(){
	       try{
	           Class.forName(this.dbDriver);
	           conn=DriverManager.getConnection(this.dbURL,this.dbAdmin,this.dbPass);
	       }catch(Exception e){
	           e.printStackTrace();
	       }
	    }
	   
	    public boolean closeConnection() throws Exception {
	       boolean bFlag=false;
	       if(conn!=null){
	           try{
	              conn.close();
	              bFlag=true;
	           }catch(Exception e){
	              e.printStackTrace();
	           }
	       }
	       return bFlag;
	    }
	 
	    public Connection getConnection() throws Exception {
	       return this.conn;
	    }
}
